package main

import (
	"flag"
	"fmt"
)

type Options struct {
	cmd string
	file string
}

func parseOpt() *Options {
	flag.Parse()
	if flag.NArg() == 0 {
		return &Options{ cmd: "help" }
	}

	switch flag.Arg(0) {
	case "add":
		switch flag.NArg() {
		case 1:
			return &Options { cmd: "add", file: "" }
		case 2:
			return &Options { 
				cmd: "add",
				file: flag.Arg(1),
			}
		default:
			return &Options { cmd: "help" }
		}
	case "serve":
		return &Options { cmd: "serve" }
	}
	return &Options { cmd: "help" }
}


func help() {
	s := `Usage: recp command [switches]
Manage personal cooking recipes.

Commands:
  recp add [file]     
            Add a new recipe from file. If file is not informed, open a new 
	    file in the editor.

  recp serve
            Create a local HTTP server on port 8080 to read the recipes.

Exit status is 0 if ok, 1 in case of error.`
	fmt.Println(s)
}
